-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement new streaming APIs for the System.Net.Http.Json
extensions
#89258
Implement new streaming APIs for the System.Net.Http.Json
extensions
#89258
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsImplements the proposed/approved API described in #87577.
Fixes #87577, @eiriktsarpalis
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsImplements the proposed/approved API described in #87577.
Fixes #87577, @eiriktsarpalis
|
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/tests/FunctionalTests/HttpClientJsonExtensionsTests.cs
Outdated
Show resolved
Hide resolved
…lientJsonExtensionsTests.cs Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/tests/FunctionalTests/HttpClientJsonExtensionsTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/tests/FunctionalTests/HttpClientJsonExtensionsTests.cs
Show resolved
Hide resolved
…rload - per peer feedback.
HttpClient has two main limits that apply to such requests: With the existing But if the The second limit is With How I would personally expect such an API to behave is either: Where I strongly prefer |
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/tests/FunctionalTests/HttpClientJsonExtensionsTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...ystem.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs
Outdated
Show resolved
Hide resolved
...s/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.AsyncEnumerable.cs
Show resolved
Hide resolved
…tpClientJsonExtensions.Get.AsyncEnumerable.cs Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
I don't think such an enforcement is necessary. Because of how async deserialization works in STJ, deserializing a single element does not necessitate buffering all the relevant data in memory. I would strongly recommend going for option (b) since that would be consistent with what would happen if you attempted to deserialize the same data using a regular |
Addressed in c99e708 |
But presumably, it does consume memory on the same order of magnitude to store the newly allocated object?
I might be misunderstanding the intended use of this API, but is it not meant exactly for cases where the server doesn't have all the data available immediately, and you want to consume elements as they are being produced? For example, I could connect to a server and stream state updates for the next day, potentially going over the limit? Just setting the limit really high is not the same, as I don't want any single update to OOM. |
cc @jeffhandley @ericstj for your consideration since this is adding new functionality for RC. |
It does store a state machine containing partially hydrated objects, but that wouldn't be contributing to overheads that are substantially larger than the final deserialized result.
That's correct, I meant to say that it should be consistent with the |
@IEvangelist mind reverting c99e708 in that case and only removing the |
So, the content stream will flow into the new |
Yes, the method should build the same stream in the same way as the existing core method: runtime/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.cs Lines 73 to 104 in b06b325
It might make sense to extract some of that logic in a common helper, if possible. |
Thanks for the heads up - we discussed this one and are OK with the additions given the low risk / need for feedback on this API. |
Implements the proposed/approved API described in #87577.
HttpClientJsonExtensions.Get.AsyncEnumerable.cs
HttpContentJsonExtensions.AsyncEnumerable.cs
ref
Fixes #87577, @eiriktsarpalis